input {
  {{ item.protocol }} {
    port => {{ item.port }}
    tags => ["syslog-beats"]
    client_inactivity_timeout => "600"
  }
}

filter {
  fingerprint {
    target => "[@metadata][uuid]"
    method => "UUID"
  }
}

output {
  if "syslog-beats" in[tags]{
    elasticsearch {
      hosts => ['{{ logstash_elastic_hosts | list | join(":" + logstash_elastic_port + "', '") }}:{{ logstash_elastic_port }}']
      ssl_certificate_verification => false
      ssl => {% if logstash_elastic_stack_auth | bool and logstash_elastic_stack_https | bool %}true{% else %}false{% endif %}

      user => "{{ logstash_elastic_stack_user }}"
      password => "{{ logstash_elastic_stack_pass }}"
      index => "syslog-beats-%{+YYYY.MM.dd}"
{% if logstash_version.split('.')[0] != '5' %}
      ilm_enabled => true
{% endif %}
      template => "/etc/logstash/template/elastic-syslog-beats-template.json"
      template_name => "syslog-beats"
      template_overwrite => true
      document_type => "_doc"
      document_id => "%{[@metadata][uuid]}"
    }
  }
}
